home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / MacApp / MacApp CD Release / MacApp® 2.0.1 Tutorial / Chapter 13 / UIconEdit.p < prev   
Encoding:
Text File  |  1990-10-25  |  4.8 KB  |  169 lines  |  [TEXT/MPS ]

  1. {Copyright © 1989 by Apple Computer, Inc.  All rights reserved.}
  2.  
  3. UNIT UIconEdit;
  4.  
  5.  
  6. INTERFACE
  7.  
  8.  
  9. USES
  10.     { • MacApp }
  11.     UMacApp,
  12.     
  13.     { • Toolbox }
  14.     ToolUtils;
  15.     
  16.     
  17. CONST kSignature = 'ICED';
  18.       kFileType = 'IDOC'; 
  19.  
  20.  
  21. TYPE 
  22.     TIconApplication = OBJECT(TApplication)
  23.  
  24.         PROCEDURE TIconApplication.IIconApplication(iconFileType: OSType);
  25.             {Initializes the application and globals.}
  26.  
  27.         FUNCTION  TIconApplication.DoMakeDocument(itsCmdNumber: CmdNumber): TDocument; OVERRIDE;
  28.             { Creates a document of type TIconDocument and returns a reference to it.}
  29.  
  30.     END;
  31.  
  32.  
  33.     TIconDocument = OBJECT(TDocument)
  34.     
  35.         fIconBitMap:        TIconBitMap;        { The document’s icon object.             }
  36.  
  37.         PROCEDURE TIconDocument.IIconDocument;
  38.             { Initializes the document. }
  39.  
  40.         PROCEDURE TIconDocument.Free; OVERRIDE;
  41.             { Frees allocated memory when the document is closed. }
  42.  
  43.         PROCEDURE TIconDocument.DoInitialState; OVERRIDE;
  44.             { Sets the document's data to represent a "new" document. }
  45.  
  46.         PROCEDURE TIconDocument.DoMakeViews (forPrinting: BOOLEAN); OVERRIDE;
  47.             { Creates the window and view objects when an icon document is opened.}
  48.  
  49.         PROCEDURE TIconDocument.RedrawViews;
  50.             { Causes all views representing this document to be redrawn. }
  51.  
  52.         PROCEDURE TIconDocument.DoSetupMenus; OVERRIDE;
  53.             { Sets the state of the menu items to which this class responds. }
  54.  
  55.         FUNCTION  TIconDocument.DoMenuCommand (aCmdNumber: CmdNumber): TCommand; OVERRIDE;
  56.             { Handles menu items specific to this class. }
  57.  
  58.         PROCEDURE TIconDocument.InvertIcon;
  59.             { Inverts the bits of this document's icon and redraw its views.  }
  60.  
  61.         PROCEDURE TIconDocument.Fields (PROCEDURE DoToField (fieldName: Str255;
  62.                                                                 fieldAddr: Ptr;
  63.                                                                 fieldType: INTEGER)); OVERRIDE;
  64.  
  65.     END;
  66.     
  67.  
  68.  
  69.  
  70.     TIconView = OBJECT(TView)
  71.  
  72.         fMagnification:        INTEGER;            { No. of times to magnify the icon.        }
  73.         fIconDocument:        TIconDocument;        { Reference to the view's icon document.}
  74.  
  75.         PROCEDURE TIconView.IRes (itsDocument: TDocument; itsSuperView: TView;
  76.                                       VAR itsParams: Ptr); OVERRIDE;
  77.             { Initializes the view from a resource template. }
  78.  
  79.         PROCEDURE TIconView.CalcMinSize (VAR minSize: VPoint); OVERRIDE;
  80.             { Returns the view's minimum size. }
  81.  
  82.         PROCEDURE TIconView.Draw (area: Rect); OVERRIDE;
  83.             { Draws this view. }
  84.  
  85.         PROCEDURE TIconView.DoSetupMenus; OVERRIDE;
  86.             { Sets the state of the menu items to which this class responds. }
  87.  
  88.         FUNCTION  TIconView.DoMenuCommand (aCmdNumber: CmdNumber): TCommand; OVERRIDE;
  89.             { Handles menu items specific to this class. }
  90.  
  91.         PROCEDURE TIconView.SetMagnification (magnification: INTEGER);
  92.             { Sets the view's magnification. }
  93.  
  94.         PROCEDURE TIconView.Fields (PROCEDURE DoToField (fieldName: Str255;
  95.                                                             fieldAddr: Ptr;
  96.                                                             fieldType: INTEGER)); OVERRIDE;
  97.  
  98.     END;
  99.  
  100.  
  101.  
  102.     TInvertCommand = OBJECT(TCommand)
  103.  
  104.         fIconDocument:        TIconDocument;        { The document affected by this command.}
  105.  
  106.         PROCEDURE TInvertCommand.IInvertCommand (itsIconDocument: TIconDocument);
  107.             { Initializes this command, associates it with the given document. }
  108.  
  109.         PROCEDURE TInvertCommand.DoIt; OVERRIDE;
  110.             { Implements the command's action by calling the document's Invert method. }
  111.  
  112.         PROCEDURE TInvertCommand.RedoIt; OVERRIDE;
  113.             { Redoes the command's action by calling the document's Invert method. }
  114.  
  115.         PROCEDURE TInvertCommand.UndoIt; OVERRIDE;
  116.             { Undoes the command's action by calling the document's Invert method. }
  117.         
  118.     END;
  119.  
  120.  
  121.     
  122.     TIconBitMap = OBJECT(TObject)
  123.  
  124.         fDataHandle:    Handle;                { Handle to the icon's bit map.            }
  125.  
  126.         PROCEDURE TIconBitMap.IIconBitMap;
  127.             { Initialize the IconBitMap object and allocate space for its data. }
  128.  
  129.         PROCEDURE TIconBitMap.Free; OVERRIDE;
  130.             { Free the icon's bit map. }
  131.             
  132.         PROCEDURE TIconBitMap.SetIconBitMap(theBitMap : Handle);
  133.             { Set the contents of the icon bit map to the new bit map. }
  134.             
  135.         PROCEDURE TIconBitMap.Clear;
  136.             { Clear the icon map by setting its bits to zero. }
  137.             
  138.         PROCEDURE TIconBitMap.Invert;
  139.             { Invert the icon's bit map. }
  140.             
  141.         PROCEDURE TIconBitMap.IconBitToWordBit (iconBit: Point; VAR word, bit: INTEGER);
  142.             { Convert icon bit numbers to the corresponding word and bit number. }
  143.             
  144.         FUNCTION TIconBitMap.GetBit(iconBit: Point): BOOLEAN;
  145.             { Return the state of the given bit. }
  146.             
  147.         PROCEDURE TIconBitMap.SetBit(iconBit: Point; turnBitOn: BOOLEAN);
  148.             { Set the state of the given bit as indicated. }
  149.  
  150.         PROCEDURE TIconBitMap.Draw (area: Rect);
  151.             { Draw the icon's bit map. }
  152.             
  153.         FUNCTION TIconBitMap.Copy: TIconBitMap;
  154.             { Create a new icon object which is a copy of itself. }
  155.             
  156.         PROCEDURE TIconBitMap.CopyDataTo (anIcon: TIconBitMap);
  157.             { Copy icon data to an existing icon object. }
  158.             
  159.         PROCEDURE TIconBitMap.Fields (PROCEDURE DoToField (fieldName: Str255;
  160.                                                               fieldAddr: Ptr;
  161.                                                               fieldType: INTEGER)); OVERRIDE;
  162.     END;
  163.  
  164.  
  165. IMPLEMENTATION
  166.  
  167.     {$I UIconEdit.inc1.p}
  168.  
  169. END.